ostree-prepare-root: Fix running with musl
authorWilliam Manley <will@williammanley.net>
Wed, 31 Aug 2016 16:15:48 +0000 (17:15 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 1 Sep 2016 20:17:58 +0000 (20:17 +0000)
commit2aacc6912b78e7d3158f072cd9c1b3c5d0bddc22
treed871dc0365a0584ee2e1537c0b075cf1c11b49c4
parent5424404813a3f9ca65d1d9e7a4b2efbaebef71cf
ostree-prepare-root: Fix running with musl

musl libc's implementation of `realpath` works by opening the path and then
doing a lookup in `/proc/self/fd` to find the canonical path.  This fails
if `/proc` is not mounted.  This causes problems for us if
`ostree-prepare-root` is `init` as `/proc` won't be mounted.

We have to mount `/proc` anyway for `/proc/cmdline` so this fix just
expands the scope over which `/proc` is mounted to include both our
`realpath` calls.

See also:

* http://www.openwall.com/lists/musl/2016/06/08/2 and
* http://git.musl-libc.org/cgit/musl/tree/src/misc/realpath.c?id=e738b8cbe64b6dd3ed9f47b6d4cd7eb2c422b38d

Closes: #485
Approved by: cgwalters
src/switchroot/ostree-prepare-root.c
tests/test-switchroot.sh